aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/[username]/settings.svelte
blob: e4d7b0bfb5b700e949c24f7049427e67aa3c495b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<script>
	import { AppHeader, Icon, Toggle, LocaleSelector } from '$comp';
	import { user, colorTheme } from '$lib/store';

	let setting = 'account';
	let password;
	let revealPassword = false;

	const colorThemes = [
		{ theme: 1, color1: 'from-[#F5F7FA]', color2: 'to-[#C3CFE2]' },
		{ theme: 2, color1: 'from-[#FDFCFB]', color2: 'to-[#E2D1C3]' },
		{ theme: 3, color1: 'from-[#E6E9F0]', color2: 'to-[#EEF1F5]' },
		{ theme: 4, color1: 'from-[#D5D4D0]', color2: 'to-[#EEEEEC]' },
		{ theme: 5, color1: 'from-[#F3E7E9]', color2: 'to-[#E3EEFF]' },
		{ theme: 6, color1: 'from-[#F5F7FA]', color2: 'via-[#EAF2FF] to-[#DEDFFF]' }
	];
	// need to update this to use the new backend field
	let selectedTheme = 1;

	const handleThemeClick = (colors) => {
		selectedTheme = colors.theme;
		$colorTheme = colors.color1 + ' ' + colors.color2;
	};
</script>

{#if $user}
	<AppHeader />

	<div class="my-20 px-3 md:px-0 w-full md:w-[400px] mx-auto space-y-8">
		<h1 class="text-center text-3xl md:text-4xl font-semibold mb-10">Settings</h1>

		<div class="font-bold flex justify-between items-center border-b pb-3 text-secondary">
			<button class:selected={setting === 'account'} on:click={() => (setting = 'account')}
				>ACCOUNT</button
			>

			<button class:selected={setting === 'pos'} on:click={() => (setting = 'pos')}
				>POINT OF SALE</button
			>

			<button class:selected={setting === 'security'} on:click={() => (setting = 'security')}
				>SECURITY</button
			>
		</div>

		{#if setting === 'account'}
			<div>
				<label for="language" class="font-bold block mb-1">Language</label>
				<LocaleSelector style="block py-3 w-full" />
			</div>

			<div>
				<label for="username" class="font-bold mb-1 block">Username</label>
				<input
					type="text"
					disabled
					name="username"
					value={$user.username}
					class="block border rounded-xl p-3 w-full"
				/>
			</div>

			<div class="relative">
				<label for="password" class="block font-bold block mb-1">New Password</label>
				{#if revealPassword}
					<input type="text" class="block border rounded-xl p-3 w-full" bind:value={password} />
				{:else}
					<input type="password" class="block border rounded-xl p-3 w-full" bind:value={password} />
				{/if}
				<button
					type="button"
					on:click={() => (revealPassword = !revealPassword)}
					class="absolute right-5 top-10"
				>
					<Icon icon={revealPassword ? 'eye' : 'eye-off'} />
				</button>
			</div>

			<div>
				<label for="address" class="font-bold mb-1 block">Business Address</label>
				<input type="text" name="address" class="block border rounded-xl p-3 w-full" />
			</div>

			<div>
				<div class="flex justify-between items-center">
					<span class="font-bold">Email Notifications</span>
					<Toggle id="email-notify" />
				</div>
				<p class="text-secondary mt-1 w-9/12">
					Get notified via email when a change occurs on your account or when people send you
					payments.
				</p>
			</div>

			<div>
				<div class="flex justify-between items-center">
					<span class="font-bold">SMS Notifications</span>
					<Toggle id="sms-notify" />
				</div>
				<p class="text-secondary mt-1 w-9/12">
					CoinOS will send you text notifications when this is enabled.
				</p>
			</div>

			<div>
				<span class="font-bold mb-1 block">Color Theme</span>
				<p class="text-secondary mb-1">Select from the default color themes.</p>
				{#each colorThemes as colors}
					<button
						class="mr-2 w-10 h-10 bg-gradient-to-r {colors.color1} {colors.color2} rounded-xl border-2 {selectedTheme ===
						colors.theme
							? 'border-black'
							: ''}"
						on:click={() => handleThemeClick(colors)}
					/>
				{/each}
			</div>
		{:else if setting === 'pos'}
			<div>
				<label for="currency" class="font-bold block mb-1">Local Currency</label>
				<select name="currency" class="block py-3 w-full">
					<option value="USD">USD</option>
				</select>
			</div>

			<div>
				<label for="btc-unit" class="font-bold block mb-1">Display bitcoin in:</label>
				<select disabled name="btc-unit" class="block py-3 w-full">
					<option value="SATS">Satoshi (SATS)</option>
					<option value="BTC">Bitcoin (BTC)</option>
				</select>
			</div>
		{:else}
			<div>
				<span class="font-bold mb-1">Security Pin</span>
				<p class="text-secondary mb-1">
					Set a security pin that will be used to unlock your settings and to send outgoing
					payments.
				</p>
				<button class="p-3 border rounded-3xl font-bold flex justify-center items-center"
					><Icon icon="lock" style="mr-1" /> Set Pin</button
				>
			</div>

			<div>
				<label for="auto-lock" class="font-bold mb-1">Auto-Lock Timer</label>
				<p class="text-secondary mb-1">
					Your account will go into a secure mode automatically after a specified time:
				</p>
				<select name="auto-lock" class="block py-3 w-full">
					<option value="5">5 min</option>
					<option value="10">10 min</option>
					<option value="30">30 min</option>
					<option value="60">1 hour</option>
					<option value="480">8 hours</option>
				</select>
			</div>

			<div>
				<span class="font-bold mb-1">2-Factor Authentication</span>
				<p class="text-secondary mb-1">
					Add an extra level of security to your device by enableing 2-factor authentication.
				</p>
				<button class="p-3 border rounded-3xl font-bold flex justify-center items-center"
					><Icon icon="mobile" style="mr-1" /> Set up 2FA</button
				>
			</div>
		{/if}
	</div>
{/if}

<style>
	.selected {
		color: black;
	}
</style>